package com.sxit.ecwx.model.bean;


import com.sxit.ecwx.core.utils.Formatu;


/**
 * 
 * 描述了接入系统可能的上行消息.
 * 
 */
public class BasePushMsg
{
    public int messageLength;
    public int openId;
    private int result;
    private int nsocket;
    private int netflag; //内网，外网标识0:外网 WEB1:内网  4字节
    public byte[] by;
    
    public BasePushMsg()
    {
    	
    } 
    /**
     * 通过构造方法组织消息体
     * @param by
     */
    public BasePushMsg(int operId,byte[] message)
    {
    	
 
    	by = new byte[message.length + 44]; 
    	System.out.println("message.length=="+message.length+",by=="+by.length);
    	System.arraycopy(Formatu.int2byte(by.length), 0, by, 0, 4); /* 长度. */
        System.arraycopy(Formatu.int2byte(operId), 0, by, 4, 4);/* 命令字. */
        System.arraycopy("000000000000".getBytes(), 0, by, 8, 12); /* 事务ID.*/
        System.arraycopy(Formatu.short2byte((short)0), 0, by, 20, 2); /* nReturn.*/
        System.arraycopy(Formatu.int2byte(0), 0, by, 22, 4); /* nSocket.*/
        System.arraycopy("0000000000000000".getBytes(), 0, by, 26, 16); /* IP.*/ 
        System.arraycopy(Formatu.short2byte((short)1), 0, by, 42,2); /* nNetFlag.*/
        System.arraycopy(message, 0, by, 44, message.length); /* 消息体*/
        
    	
    }
    
    
    
    /**
     * 通过构造方法组织消息体
     * @param by
     */
    public BasePushMsg(String uuid,int operId,byte[] message)
    {
    	by = new byte[message.length + 12+uuid.length()]; 
    	System.out.println("message.length=="+message.length+",by=="+by.length);
    	System.arraycopy(Formatu.int2byte(by.length), 0, by, 0, 4); /* 长度. */
        System.arraycopy(Formatu.int2byte(operId), 0, by, 4, 4);/* 命令字. */
        System.arraycopy(uuid.getBytes(), 0, by, 8, 36); /* 事务ID.*/
        System.arraycopy(Formatu.int2byte(0), 0, by, 44, 4); /* nSocket.*/
        System.arraycopy(message, 0, by, 48, message.length); /* 消息体*/	
    }
    
	public int getMessageLength() {
		return messageLength;
	}
	public void setMessageLength(int messageLength) {
		this.messageLength = messageLength;
	}
	public int getOpenId() {
		return openId;
	}
	public void setOpenId(int openId) {
		this.openId = openId;
	}
	public int getResult() {
		return result;
	}
	public void setResult(int result) {
		this.result = result;
	}
	public int getNsocket() {
		return nsocket;
	}
	public void setNsocket(int nsocket) {
		this.nsocket = nsocket;
	}
	public int getNetflag() {
		return netflag;
	}
	public void setNetflag(int netflag) {
		this.netflag = netflag;
	}
	public byte[] getBy() {
		return by;
	}
	public void setBy(byte[] by) {
		this.by = by;
	}
    
}
